package org.black.missedCall2;

import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.preference.DialogPreference;
import android.preference.PreferenceManager;
import android.util.AttributeSet;

public class MissedCallRestoreToDefaultSettingsDialogPreference extends
		DialogPreference {

	public MissedCallRestoreToDefaultSettingsDialogPreference(Context context,
			AttributeSet attrs) {
		super(context, attrs);
		this.setPersistent(false);

		this.setDialogLayoutResource(R.layout.missed_call_restore_to_default_dialog);
	}

	@Override
	protected void onPrepareDialogBuilder(Builder builder) {
		super.onPrepareDialogBuilder(builder);
		builder.setPositiveButton(android.R.string.ok, new OnClickListener() {

			@Override
			public void onClick(DialogInterface dialog, int which) {
				SharedPreferences sharedPreferences = PreferenceManager
						.getDefaultSharedPreferences(getContext());
				Editor editor = sharedPreferences.edit();
				editor.clear();
				editor.commit();
			}
		});
	}

}
